package cn.tedu.shoot;
import javax.imageio.ImageIO;
import javax.swing.*;
import java.awt.image.BufferedImage;


/** 图片工具类 */
public class Images {

    public static ImageIcon start;          //启动图片
    public static ImageIcon pause;          //暂停图片
    public static ImageIcon gameover;       //游戏结束图片
    public static ImageIcon background;     //天空图片
    public static ImageIcon bullet;         //子弹图片
    public static ImageIcon[] heros;        //英雄机图片数组
    public static ImageIcon[] airplanes;    //小敌机图片数组
    public static ImageIcon[] bigairplanes; //大敌机图片数组
    public static ImageIcon[] bees;         //小蜜蜂图片数组

    static {
        start = new ImageIcon("img/start.png");
        pause = new ImageIcon("img/pause.png");
        gameover = new ImageIcon("img/gameover.png");
        background = new ImageIcon("img/background.png");
        bullet = new ImageIcon("img/bullet.png");
        heros = new ImageIcon[2]; //2张图片
        heros[0] = new ImageIcon("img/hero0.png");
        heros[1] = new ImageIcon("img/hero1.png");

        airplanes = new ImageIcon[5]; //5张图片
        bigairplanes = new ImageIcon[5]; //5张图片
        bees = new ImageIcon[5]; //5张图片
        airplanes[0] = new ImageIcon("img/airplane.png");
        bigairplanes[0] = new ImageIcon("img/bigairplane.png");
        bees[0] = new ImageIcon("img/bee.png");
        for(int i=1;i<airplanes.length;i++){ //赋值爆破图
            airplanes[i] = new ImageIcon("img/bom"+i+".png");
            bigairplanes[i] = new ImageIcon("img/bom"+i+".png");
            bees[i] = new ImageIcon("img/bom"+i+".png");
        }
    }

    public static void main(String[] args) {
        System.out.println(start.getImageLoadStatus());
        System.out.println(pause.getImageLoadStatus());
        System.out.println(gameover.getImageLoadStatus());
        System.out.println(background.getImageLoadStatus());
        System.out.println(bullet.getImageLoadStatus());
        System.out.println(heros[0].getImageLoadStatus());
        System.out.println(heros[1].getImageLoadStatus());
        for (int i = 0; i < airplanes.length; i++) {
            System.out.println(airplanes[i].getImageLoadStatus());
            System.out.println(bigairplanes[i].getImageLoadStatus());
            System.out.println(bees[i].getImageLoadStatus());
        }
    }




//    //  公开的  静态的   图片数据类型  变量名
//    public static BufferedImage start;    //启动图片
//    public static BufferedImage pause;    //暂停图片
//    public static BufferedImage gameover; //游戏结束图片
//    public static BufferedImage sky;      //天空图片
//    public static BufferedImage bullet;   //子弹图片
//    public static BufferedImage[] heros;  //英雄机图片数组
//    public static BufferedImage[] airs;   //小敌机图片数组
//    public static BufferedImage[] bairs;  //大敌机图片数组
//    public static BufferedImage[] bees;   //小蜜蜂图片数组
//
//    static { //给图片赋值
//        start = readImage("start.png");
//        pause = readImage("pause.png");
//        gameover = readImage("gameover.png");
//        sky = readImage("background.png");
//        bullet = readImage("bullet.png");
//        heros = new BufferedImage[2]; //2张图片
//        heros[0] = readImage("hero0.png");
//        heros[1] = readImage("hero1.png");
//
//        airs = new BufferedImage[5]; //5张图片
//        bairs = new BufferedImage[5]; //5张图片
//        bees = new BufferedImage[5]; //5张图片
//        airs[0] = readImage("airplane.png");
//        bairs[0] = readImage("bigairplane.png");
//        bees[0] = readImage("bee.png");
//        for(int i=1;i<airs.length;i++){ //赋值爆破图
//            airs[i] = readImage("bom"+i+".png");
//            bairs[i] = readImage("bom"+i+".png");
//            bees[i] = readImage("bom"+i+".png");
//        }
//    }
//
//    /** 读取图片  fileName:图片名称 */
//    public static BufferedImage readImage(String fileName){
//        try{
//            BufferedImage img = ImageIO.read(FlyingObject.class.getResource(fileName)); //读取与FlyingObject同包中的图片
//            return img;
//        }catch(Exception e){
//            e.printStackTrace();
//            throw new RuntimeException();
//        }
//    }

//    public static void main(String[] args) {
//       // System.out.println(Images.heros.length); //测试代码只要用到Images类就OK
//    }
}